package com.tf_cut.admin.seller.controller;

import com.alibaba.fastjson.JSON;
import com.tf_cut.admin.backend.api.BackEndApi;
import com.tf_cut.admin.common.pojo.PageInfo;
import com.tf_cut.admin.common.pojo.Result;
import com.tf_cut.admin.platform.vo.RechargeVo;
import com.tf_cut.admin.seller.vo.SellerBillAndConsigneeVo;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@RestController
@RequestMapping("/seller/bill")
@Slf4j
public class SellerBillController {

    @Autowired
    private BackEndApi sellerBillApi;

    @GetMapping("list")
    public ModelAndView sellerList() {
        return new ModelAndView("seller/bill/list", "sellerBill", null);
    }

    @PostMapping("list/page")
    public Result<PageInfo<SellerBillAndConsigneeVo>> page(SellerBillAndConsigneeVo sellerBillAndConsigneeVo) {
        String json = JSON.toJSONString(sellerBillAndConsigneeVo);
        json = sellerBillApi.querySellerBillList(json);
        return Result.of(JSON.parseObject(json, PageInfo.class));
    }
    
    
    
    @RequestMapping("/findBybill")
    public Result<List<SellerBillAndConsigneeVo>> findBybill(@RequestParam("sellerCompanyName") String sellerCompanyName,
    		@RequestParam("status") String status,@RequestParam("startDate") String startDate,
            @RequestParam("endDate") String endDate) {
    	List<SellerBillAndConsigneeVo> list = sellerBillApi.findBybill(sellerCompanyName,status,startDate,endDate);
    	 return Result.of(list);
    }

}
